<%@ page language="java"  pageEncoding="UTF-8"%>
<%@ include file="/views/commons/taglibs.jsp" %>
<div class="panel-heading">
	<div class="pull-right">
		<a href="<%=path %>/base/permission/toInsert" target="_blank">创建权限</a>
	</div>
	<h3 class="panel-title">权限列表</h3>
</div>
<div class="bd clearfix">
	<form id="base_permission_choose_form" action="javascript:void(0);">
		<div class="filter-wrap">
			<dl class="clearfix invest-filter">
				<dt>权限名称</dt>
				<dd class="clearfix">
					<div class="col-sm-4 mb20">
						<div class="input-group">
							<input type="text" name="permissionName" value="${paramMap.permissionName}" class="form-control" placeholder="请输入权限名称关键字">
							<span class="input-group-btn">
								<button class="btn btn-primary" type="button" onclick="javascript:queryPermissionList(1);">搜索</button>
							</span>
						</div>
					</div>
				</dd>
			</dl>
			<dl class="clearfix invest-filter">
				<dt>权限key</dt>
				<dd >
					<div class="col-sm-5 mb20">
						<div class="input-group">
							<input type="text" name="permissionKey" size="30" value="${paramMap.permissionKey}" class="form-control" placeholder="请输入权限key">							
						</div>
					</div>
				</dd>
			
				<dt>访问URL</dt>
				<dd >
					<div class="col-sm-5 mb20">
						<div class="input-group">
							<input type="text" name="permissionUrl" size="30" value="${paramMap.permissionUrl}" class="form-control" placeholder="请输入权限对应的访问URL关键字">							
						</div>
					</div>
				</dd>
			</dl>
		</div>
	</form>
</div>
<c:choose>
<c:when test="${!empty dataList && fn:length(dataList) ne 0}">
<table class="table">
	<thead>
		<tr>
			<th width="20%">权限名称</th>
			<th width="20%">权限key</th>
			<th width="30%">权限对应的URL</th>
			<th width="30%">操作</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="permissionVO" items="${dataList}" varStatus="index">
		<tr>
			<td class="title">
				<a href="<%=path %>/base/permission/toUpdate/${permissionVO.permissionId}" target="_blank">${permissionVO.permissionName}</a>
			</td>
			<td>${permissionVO.permissionKey}</td>
			<td>${permissionVO.permissionUrl}</td>
			<td>
				<a href="javascript:deletePermission('${permissionVO.permissionId}')" >删除权限</a>
				<a href="<%=path %>/base/permission/view/${permissionVO.permissionId}" target="_blank">给角色分配权限</a>
			</td>
		</tr>
		</c:forEach>
	</tbody>
</table>
<!-- 分页 -->
<p:pagination pageNo="${paramMap.pageNo}" pageCount="${paramMap.pageCount}" queryFunction="queryPermissionList" style="text-center"></p:pagination>
<!-- 分页 end -->
</c:when>
<c:otherwise>
	<table class="table">
		<thead>
			<tr>
				<th width="20%">权限名称</th>
				<th width="20%">权限key</th>
				<th width="30%">权限对应的URL</th>
				<th width="30%">操作</th>
			</tr>
		</thead>
		<tbody>
			<tr>
				<td colspan="4" align="center">
					暂无数据
				</td>
			</tr>
		</tbody>
	</table>
</c:otherwise>
</c:choose>
<script type="text/javascript">
	function deletePermission(permissionId) {
		$.ajax({
			url : path + "/base/permission/delete/" + permissionId,
			type : "post",
			dataType : "json",
			success : function(data) {
				if (data.result) {
					layer.msg("删除商品成功", {
						icon : 1
					});
					queryPermissionList(1);
				} else {
					layer.msg(data.message, {
						icon : 2
					});
					;
				}
			},
			error : function() {
				layer.msg("服务器网络繁忙", {
					icon : 2
				});
			}
		});
	}
</script>